mod cards;
mod history;
mod starter;

use cards::{CardUI, Cards};
use history::{HisHand, History};
use starter::PokerGame;

use dioxus::prelude::*;
use dioxus_router::prelude::*;
use poker::{Hand, DECK_OF_CARDS};

#[rustfmt::skip]
#[derive(Clone, Debug, PartialEq, Routable)]
pub(crate) enum Route {
    #[layout(Main)]
        #[route("/play")]
        History {},
        #[route("/")]
        Cards {}
}

#[derive(Clone, PartialEq, Eq)]
enum GameState {
    OurHandEditing,
    OpponentHandEditing,
    Playing,
}

#[derive(Clone)]
struct OurHand(Hand);
#[derive(Clone)]
struct OpponentHand(Hand);
#[derive(Clone)]
struct RemainHand(Hand);

static GAME_STATE: GlobalSignal<GameState> = Signal::global(|| GameState::OpponentHandEditing);
static REMAIN_HAND: GlobalSignal<RemainHand> = Signal::global(|| RemainHand(DECK_OF_CARDS));
static OUR_HAND: GlobalSignal<OurHand> = Signal::global(|| OurHand(Hand::default()));
static OPPONENT_HAND: GlobalSignal<OpponentHand> = Signal::global(|| OpponentHand(Hand::default()));
static HIS_HANDS: GlobalSignal<Vec<HisHand>> = Signal::global(Vec::<HisHand>::new);

fn Main() -> Element {
    rsx!(
        main { class: "min-w-200 min-h-fit bg-cover bg-white p-6",
            section { class: "flex min-h-full min-w-full justify-center m-0 space-x-4",
                PokerGame {}
                Outlet::<Route> {}
            }
        }
    )
}
